import request from '../utils/request'

/**
 * 获取所有的商品分类
 * @param {Object} params {type, pagenum, pagesize}
 * @returns promise
 */
export const getAllCate = params => request({
    url:'categories',
    params
})

/**
 * 增加分类
 * @param {Object} data {cat_pid, cat_name, cat_level}
 * @returns promise
 */
export const addCateAPI = data => request({
    method: 'post',
    url: 'categories',
    data
})

/**
 * 编辑分类
 * @param {number} id 分类ID
 * @param {string} cat_name 分类名称
 * @returns promise
 */
export const editCateAPI = (id, cat_name) => request({
    method: 'put',
    url: `categories/${id}`,
    data: {
        cat_name
    }
})

/**
 * 删除分类
 * @param {number} id 分类ID
 * @returns promise
 */
export const delCateAPI = id => request({
    method: 'delete',
    url: `categories/${id}`
})